/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__frct_free.c                                     */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/17 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frcomm.h"
#include "frlog.h"
#include "frmem.h"
#include "frlist.h"
#include "frsutl.h"
#include "frhash2.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frct_mng.h"
#include "apmtest_cunit.h"

static int __suite_init(void)
{
	return 0;
}

static int __suite_cleanup(void)
{
	return 0;
}

extern void __frct_free(Conntrack *p_st_ct);
extern struct event_base *g_p_st_ebase;
extern int g_i_flag_run;
extern Frhash_header        *g_p_st_hash_ct;

static void __case1(void)
{
    Conntrack *p_st_ct = NULL;

    __frct_free(p_st_ct);
}


static void __case2(void)
{
    Conntrack *p_st_ct = NULL;
    Conntrack *p_st_ct1 = NULL;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct, 0x00, sizeof(Conntrack));
    p_st_ct1 = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct1, 0x00, sizeof(Conntrack));

    __frct_free(p_st_ct);
    __frct_free(p_st_ct1);

}

static void __case3(void)
{
    Conntrack *p_st_ct = NULL;
    Frlist_node *p_st_node = NULL;
    L7_analyzer *p_L7_analyzer = NULL;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct, 0x00, sizeof(Conntrack));

    __frct_free(p_st_ct);

    frct_destroy();

}

int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t__frct_free 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
//    CU_add_test(pSuite, "case4", __case4);

    //增加测试用例


    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}